<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <title>后台首页</title>
    <base href="<%=basePath%>">
    <link rel="stylesheet" href="../resource/layui/css/layui.css">
    <link rel="stylesheet" href="center/css/contabs.min.css" >
    <link rel="stylesheet" href="center/css/contabs_font.css" >
    <script src="../resource/layui/layui.js"></script>
    <script src="center/js/jquery.min.js"></script>
    <script src="center/js/contabs.min.js"></script>

  <script type="text/javascript">
      var layer  ;
      //JavaScript代码区域
      layui.use(['element','layer'], function(){
          var element = layui.element,
              layer=layui.layer;
      });
  </script>

</head>
<body>
<!-- 顶部导航 -->
<div class="layui-header">
    <div class="layui-logo">
        小飞侠综合管理平台
    </div>
    <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-nav-child2 xi_icon" style="margin-right:20px">
            <i class="layui-icon in_iconfont xi_icon2">&#xe611;</i>
            <a class="J_menuItem" href="message_notification.html">
                消息通知
                <span style="display:inline-block;height:16px;padding:0 5px;background-color:#FF3333;font-size:13px; line-height:16px;-webkit-border-radius:100px;-webkit-border-radius:100px;border-radius:100px; margin:0 1px">3</span>

                <dl class="layui-nav-child layui-nav-child2" id="notice" style="padding:5px 0; left:-15px;">
                    <dd><a class="layui_nav_ab J_menuItem J_menuItemsss" onclick="showDetail()">消息1</a></dd>
                    <dd><a class="layui_nav_ab J_menuItem J_menuItemsss" onclick="showDetail()">消息1</a></dd>
                    <dd><a class="layui_nav_ab J_menuItem J_menuItemsss" href="javascript:void(0);">更多消息</a></dd>
                </dl>
            </a>
        </li>
        <li class="layui-nav-item xi_icon">
            <i class="layui-icon in_iconfont xi_icon2">&#xe612;</i>
            <a href="javascript:;">
                ${sessionScope.user.name}
            </a>
            <dl class="layui-nav-child layui-nav-child2">
                <dd><a class="layui_nav_ab J_menuItem" href="personInfo.html">基本资料</a></dd>
                <dd><a class="layui_nav_ab J_menuItem" href="changepwd.html">密码修改</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="../../index.jsp">
                退出
            </a>
        </li>
    </ul>
</div>
<!-- 左侧导航 -->
<div class="layui-side layui-bg-bai">
    <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree"  lay-filter="test">
            <li style="display:none;" class="layui-nav-item layui-nav-child">
                <a id="zhuye" class="layui_nav_a J_menuItem" href="center/main.jsp">首页</a>
            </li>
            <li class="layui-nav-item"><!--layui-nav-itemed-->
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont">&#xe656;</i>普通流程</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="flow/deployed/index">可发起</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flow/db/index">待处理</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flow/jxz/index">进行中</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flow/history/index">已完结</a></dd>
                </dl>
            </li>

            <li class="layui-nav-item"><!--layui-nav-itemed-->
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont">&#xe656;</i>会审流程</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="flow/deployed/index">可发起</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flowhs/db/index">待处理</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flowhs/jxz/index">进行中</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flowhs/history/index">已完结</a></dd>
                </dl>
            </li>

            <li class="layui-nav-item">
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont">&#xe629;</i>报表管理</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="report_form.html">报表管理</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont" style="font-size:14px">&#xe613;</i>用户管理</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="user/index">用户管理</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont">&#xe614;</i>系统管理</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="depart/index">部门管理</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="menu/index">菜单管理</a></dd>

                    <dd><a class="layui_nav_a J_menuItem" href="system_log.html">日志管理</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="system_dictionary.html">字典管理</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="system_role.html">角色管理</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a class="" href="javascript:;"><i class="layui-icon in_iconfont">&#xe641;</i>流程部署管理</a>
                <dl class="layui-nav-child layui-nav-child2">
                    <dd><a class="layui_nav_a J_menuItem" href="flow/index">可部署</a></dd>
                    <dd><a class="layui_nav_a J_menuItem" href="flow/deploy/index">已部署</a></dd>
                </dl>
            </li>
        </ul>
    </div>
</div>
<!-- 右侧主体 -->
<div class="layui-body">
    <!--tab标签-->
    <div class="row content-tabs">
        <button class="roll-nav roll-left J_tabLeft"><i class="fa fa-angle-double-left"></i></button>
        <nav class="page-tabs J_menuTabs">
            <div class="page-tabs-content">

            </div>
        </nav>
        <button class="roll-nav roll-right J_tabRight"><i class="fa fa-angle-double-right"></i></button>
        <a class="roll-nav roll-right J_tabExit" href="javascript:;"><i class="fa fa fa-refresh"></i></a>
    </div>
    <!--tab标签结束-->

    <!--tab内容-->
    <div class="row J_mainContent" id="content-main">
        <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="center/main.jsp" frameborder="0" data-id="" seamless> </iframe>
    </div>
    <!--tab内容结束-->
    <script>
        $(function(){
            $('#zhuye').click();
        });
    </script>
</div>
<!-- 底部固定区域 -->
<div class="layui-footer">
    2018 © 小飞侠
</div>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;
    });
</script>


<script type="text/javascript">
    function updatepwa(){
        parent.layer.open({
            type:2,
            btn: ['确定', '取消'],
            area: ['100%', '100%'],
            skin: 'layui-layer-lan',
            title: titles ,
            shade: [0.5, '#393D49'],
            maxmin: true, //开启最大化最小化按钮
            content:"",
            yes:function(index,frameDom){
                var openFrame = $(frameDom).find("iframe")[0].contentWindow; // 窗口
                openFrame.update();
                parent.layer.close(index);//关闭当前窗口
            }
        });
    }

    function showNotice() {
        $("#notice").html('');//清空以前的数据
        var url = "${path}/notice/query";
        var datas = {"page":1,"row":5,"type":0,"isRead":0,"state":1,"reserveid":"${_sessionUser.userid}"};
        $.ajax({
            url:url,
            type:"POST",
            data:datas,
            async:false,
            dataType:"json",
            success:function(data){
                var list = data.data;//获取数据
                if(list!=null && list.length>0){
                    var appendHtml = "";
                    for(var i=0;i<list.length;i++){
                        var notice = list[i];
                        var id = notice.id;
                        var title = notice.title;
                        var content = notice.content;
                        var startDate = notice.startdate;//要使用有效开始时间。
                        appendHtml +=
                            '<dd><a class="layui_nav_ab J_menuItem J_menuItemsss" onclick="showDetail(\''+id+'\')">'+content+'</a></dd>';
                    }
                    if(list.length >=5){
                        appendHtml +='<dd><a class="layui_nav_ab J_menuItem J_menuItemsss" href="${path}/notice/more?type=0&opt=head">更多>></a></dd>';
                    }
                }else{
                    appendHtml = '<dd><a class="layui_nav_ab J_menuItem J_menuItemsss" >暂无新通知。</a></dd>';
                }
                $("#notice").append(appendHtml);
            },
            error:function(data){
                console.log("加载通知公告异常！");
            }
        });
    }
    function showDetail(id){
        parent.layer.open({
            type:2,
            btn: ['确定', '取消'],
            area: ['100%', '100%'],
            skin: 'layui-layer-lan',
            title: '通知' ,
            shade: [0.5, '#393D49'],
            maxmin: true, //开启最大化最小化按钮
            content:"${path}/notice/head/info?id="+id,
            yes:function(index,frameDom){
                parent.layer.close(index);//关闭当前窗口
            },
            end: function(){
                initNum();//初始化未读消息数量
                showNotice();//初始化未读消息
                //获取 mian.htm的iframe
                var parentwin = window.document.getElementsByTagName("iframe")[1].contentWindow;//父级窗口刷新
                parentwin.showNotice(0,'noticetz');//加载通知 是根据 个人ID查的
            }
        });
    }

    function initNum() {//初始化未读消息数量
        var ajaxUrl = "${path}/notice/query/read";//获取未读消息
        $.ajax({
            type: "POST",
            url: ajaxUrl,
            dataType:"json",
            data: {"type":0,"isRead":0,"reserveid":"${_sessionUser.userid}"},
            async: true,
            success: function (data) {
                var res = data.result;
                if((res!=null && res!="") || res == 0 ){
                    if(res != '' && res != 0){
                        $("#readnum").css({"height":"16px","padding":"0 5px","background-color":"#FF3333",
                            "font-size":"12px","line-height":"17px","-webkit-border-radius":"100px","border-radius":"100px"});
                    } else {
                        $("#readnum").hide();
                    }
                    $("#readnum").html(res);
                }
            },
            error: function(data) {
                console.log("出错："+data);
            }
        });
    }

    $(function () {
        //initNum();//初始化未读消息数量
        //showNotice();//初始化未读消息
    });
</script>

</body>
</html>
